import { dateYMD, dateZMD, dateHMS, dateHM, dateZHM } from "../utils/index";
export function translateDateYMD(val) {
  return dateYMD(val);
}

export function translateDateMD(val) {
  return dateZMD(val);
}

export function translateDateHMS(val) {
  return dateHMS(val);
}

export function translateDateHM(val) {
  return dateHM(val);
}

export function translateDateZHM(val) {
  return dateZHM(val);
}

export function translateDateZh(val) {
  if (!val) return "";

  val *= 1;

  return `${translateDateYMD(val)} ${translateDateHMS(val)}`;
}

/**
 * @description 将数字转换成K为单位的字符
 * @param {Number} val
 * @returns {String}
 * 23 => 23
 * 1122 => 1.1K
 */
export function thousandsTranslate(val = 0) {
  if (!/^\d+$/.test(val)) return val;
  if (val < 1000) return val;

  let th = Math.floor(val / 1000) * 100;
  let decimal = Math.round((val % 1000) / 10);

  return (th + decimal) / 100 + "K";
}
